﻿@model PlanningPokerMVC.Models.DashboardViewModel

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<script>

    $(document).ready(function() {
        $("#treeview").kendoTreeView();
    });


    $(document).ready(function () {
        $("#chart").kendoChart({
            title: {
                text: "Epic Story Point Breakdown"
            },
            dataSource: {
                transport: {
                    read: {
                        url: "/Dashboard/EpicReport",
                        dataType: "json"
                    }
                },
                sort: {
                    field: "EpicName",
                    dir: "asc"
                }
            },
            seriesDefaults: {
                type: "column",
                labels: {
                    visible: true,
                    format: "{0} Story Points"
                }
            },
            series: [{
                field: "ActiveTotal",
                name: "Active"
            }, {
                field: "ResolvedTotal",
                name: "Resolved"
            }
            ],



            categoryAxis: {
                field: "EpicName"
            },
            valueAxis: {
                majorUnit: 1000,
                labels: {
                    format: "{0} Story Points"
                }

            }
        });
    });

    
</script>

<h2>Epic User Story Point Breakdown</h2>

<div id="chart"></div>

<h2>Work Item Tree</h2>

<ul id="treeview">
@foreach (var item in Model.WorkItems)
{
                <li>
            
                @item.Title
                <br />
            
                @if (item.WorkItemType == AgileDashboard.Entities.WorkItemType.User_Story)
                {
                    @String.Format("Story Points: {0}", ((AgileDashboard.Entities.UserStory)item).StoryPoints)
                    <br />
                }
                



    <ul>
        @foreach (var item2 in item.LinkedWorkedItems)
        {
            <li>
            
            @item2.Title
            <br />
            
                @if (item2.WorkItemType == AgileDashboard.Entities.WorkItemType.User_Story)
                {
                    @String.Format("Story Points: {0}", ((AgileDashboard.Entities.UserStory)item2).StoryPoints)
                    <br />
                }
                


                @foreach (var item3 in item2.LinkedWorkedItems)
                {
                    <ul>
                        <li>
            
                        @item3.Title
                        <br />
            
                            @if (item3.WorkItemType == AgileDashboard.Entities.WorkItemType.User_Story)
                            {
                                @String.Format("Story Points: {0}", ((AgileDashboard.Entities.UserStory)item3).StoryPoints)
                                <br />
                            }
         
                        </li>
                    </ul>
                }

         
            </li>
        }
        </ul>
        </li>
}

</ul>



@*<table id="projects" width="100%">
<thead>
    <tr>
        <th>Project Id</th>
        <th>Name</th>
    </tr>
</thead>
<tbody>
    @foreach (var item in Model.Projects)
    {
        <tr data-pkey="@item.Id">
            <td>@Html.DisplayFor(modelItem => item.Id)</td>
            <td>@Html.DisplayFor(modelItem => item.Name)</td>
        </tr>
    }
</tbody>
</table>*@

@*
<table id="queries" width="100%">
<thead>
    <tr>
        <th>Query Id</th>
        <th>Name</th>
    </tr>
</thead>
<tbody>
    @foreach (var item in Model.Queries)
    {
        <tr data-pkey="@item.Id">
            <td>@Html.DisplayFor(modelItem => item.Id)</td>
            <td>@Html.DisplayFor(modelItem => item.Name)</td>
        </tr>
    }
</tbody>
</table>*@

@*
<table id="workItems" width="100%">
<thead>
    <tr>
        <th>Id</th>
        <th>Title</th>
        <th>Estimate</th>
    </tr>
</thead>
<tbody>
    @foreach (var item in Model.WorkItems)
    {
        <tr data-pkey="@item.Id">
            <td>@Html.DisplayFor(modelItem => item.Id)</td>
            <td>@Html.DisplayFor(modelItem => item.Title)</td>
            
             @if (item.WorkItemType == AgileDashboard.Entities.WorkItemType.User_Story)
            {
                    <td>@(((AgileDashboard.Entities.UserStory)item).StoryPoints) </td>
            }
            else
            {
                <td>N\A</td>
            }
        </tr>
            if (item.LinkedWorkedItems != null)
            {
            <table width="100%">
            <thead>
                <tr>

                    <th>Id</th>
                    <th>Title</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var level1Item in item.LinkedWorkedItems)
                {
                    <tr data-pkey="@item.Id">
                        <td>@Html.DisplayFor(modelItem => level1Item.Id)</td>
                        <td>@Html.DisplayFor(modelItem => level1Item.Title)</td>                 
                
             
                @if (level1Item.WorkItemType == AgileDashboard.Entities.WorkItemType.User_Story)
                {
                       <td>@(((AgileDashboard.Entities.UserStory)level1Item).StoryPoints) </td>
                }
                else
                {
                    <td>N\A</td>
                }

                    </tr>
                        if (item.LinkedWorkedItems != null)
                        {


                        }

                }
            </tbody>
            </table>

        }

    }
</tbody>
</table>*@

